#!/usr/bin/env python
# -*- coding:utf-8-*-
import urllib
import urllib2

key = raw_input("请输入要翻译的单词：")
url = "http://fy.iciba.com/ajax.php?a=fy"

formatdata = {
    "f": "auto",
    "t": "auto",
    "w": key
}

ua = {
    "Connection" : "keep-alive",
    "Accept" : "application/json, text/javascript, */*; q=0.01",
    "X-Requested-With" : "XMLHttpRequest",
    "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
    "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8",
    "Accept-Language" : "zh-CN,zh;q=0.9"
}

data = urllib.urlencode(formatdata)
print(data)
request = urllib2.Request(url, data=data, headers=ua)

reponse = urllib2.urlopen(request)

print(reponse.read())